<%@page import="utils.Printer"%>
<%@ page language="java" contentType="text/html; charset=windows-1255"
    pageEncoding="windows-1255"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1255" />
<link href="style.css" rel="stylesheet" type="text/css" />
<% String courseName = request.getParameter("course_name"); %>
<title><%= courseName +" " %> Details</title>

<script type="text/javascript">
function setEndTime(){

	var startTimeSelect = document.getElementById("start_time");
	var endTimeSelect = document.getElementById("end_time");
	endTimeSelect.innerHTML = "";
	
	for (var i = 1; i <= 4; i++) {
		var endTime = Number(startTimeSelect.value) + i;
		
		if (endTime > 19) {
			break;
		}
		
		endTimeSelect.innerHTML += '<option value="' + endTime + '">' + endTime + ':00</option>';
		
	}
}

</script>
</head>
<body onload="setPage('manage_courses');setEndTime();">

<%	
if (request.getSession(false) == null || request.getSession(false).getAttribute("username") == null){
	response.sendError(HttpServletResponse.SC_FORBIDDEN, "Please login first");
	return;
}
		
%>

<%@ include file="WEB-INF/private/body_wrapper_header.html" %>

<h1> <%= courseName %></h1>
<% Printer.printCourseDescription(getServletContext(), out, courseName); %>

<br /><br />
<% boolean isActive = Printer.printCourseSessions(getServletContext(), "RemoveSessionFromCourse", out, courseName); %>
<br /><br />


<% if (!isActive) { %>
<h3> Add new Session</h3>
Each session is one hour <br />
<form method="post" action="AddSessionToCourse"><p>

<input type="hidden" name="course_name" value= "<%= courseName %>"></input>

Day: 
<select name="day">
  <option value="1" selected="selected">Sunday</option>
  <option value="2">Monday</option>
  <option value="3">Tuesday</option>
  <option value="4">Wednesday</option>
  <option value="5">Thursday</option>
  <option value="6">Friday</option>
  <option value="7">Saturday</option>
</select>

Start Time:
<select name="start" id="start_time" onChange="setEndTime()">
  <option value="9" selected="selected">09:00</option>
  <option value="10">10:00</option>
  <option value="11">11:00</option>
  <option value="12">12:00</option>
  <option value="13">13:00</option>
  <option value="14">14:00</option>
  <option value="15">15:00</option>
  <option value="16">16:00</option>
  <option value="17">17:00</option>
  <option value="18">18:00</option>
</select>

End Time:
<select name="end" id="end_time">
</select>

<input type="submit" value="Add"></input>
</p></form>


<form method="post" action="ActivateCourse"><p>
<input type="hidden" name="course_name" value="<%=courseName %>" />
<input type="submit" value="Activate Course" />
</p></form>
<h4>Note that after activating the course, it will be impossible to edit sessions</h4>
<% } %>



<%@ include file="WEB-INF/private/body_wrapper_footer.html" %>
</body>
</html>